﻿using System.Drawing;
using System.IO;
using AmiDraw.Lib.Factory;
using AmiDraw.Lib.Models;
using PropertyChanged;

namespace AmiDraw.Lib
{
    [AddINotifyPropertyChangedInterface]
    public class ImageElement : MultiplotElemtentBase
    {
        public override string Name => "Image";

        public override string Description => "绘制一个图片元素";

        /// <summary>
        /// 位于datas\image 下面的名字
        /// </summary>

        public string ImageResKey { get; set; } = "";

        public override void Draw(Graphics graphics, string packName, ResultQueryMode mode = ResultQueryMode.Core)
        {
            using (FileStream stream = new FileStream(PathFactory.GetResImagePath(packName, ImageResKey, mode), FileMode.Open))
            {
                var image = Image.FromStream(stream);
                var rect = new RectangleF((float)X, (float)Y, (float)Height, (float)Width);
                graphics.DrawImage(image, rect);
            }
        }
    }
}
